#include "Thread.hpp"
#include <unordered_map>
#include <memory>

#define NUM 10

using thread_ptr_t=std::shared_ptr<ThreadModule::Thread>;

int main()
{
    //创建多线程
    std::unordered_map<std::string, thread_ptr_t> threads;
    for(int i=0;i<NUM;i++)
    {
        thread_ptr_t t=std::make_shared<ThreadModule::Thread>([](){
            while(true)
            {
                std::cout<<"hello"<<std::endl;
                sleep(1);
            }
        });
        threads[t->Name()]=t;
    }

    for(auto& thread : threads)
    {
        thread.second->Start();
    }

    for(auto& thread : threads)
    {
        thread.second->Join();
    }
    
    // ThreadModule::Thread t([](){
    //     while(true)
    //     {
    //         std::cout<<"hello"<<std::endl;
    //         sleep(1);
    //     }
    // });

    // t.Start();
    // std::cout<<t.Name()<<std::endl;
    // t.Join();
    return 0;
}